﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ReadeAssetManager
{
    public partial class ucReports : UserControl
    {
        private AMSServiceRef.User _user;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="CurrentUser">[AMSServiceRef.User] The current application user.</param>
        public ucReports(AMSServiceRef.User CurrentUser)
        {
            InitializeComponent();
            _user = CurrentUser;
        }

        /// <summary>
        /// btnTotalValue_Click
        /// </summary>
        /// <param name="sender">[object] The btnTotalValue control.</param>
        /// <param name="e">[EventArgs] The standard event arguments for a Click event.</param>
        private void btnTotalValue_Click(object sender, EventArgs e)
        {
            double total = 0.0;

            foreach(AMSServiceRef.Asset a in _user.Assets)
            {
                foreach (AMSServiceRef.PurchaseData p in a.Purchases)
                {
                    total += p.Price;
                }
            }

            MessageBox.Show("The total value of your assets is " + string.Format("{0:C}", total), "Total Value");
        }
    }
}
